# Uses:
#
# PDD_CONV_DIFF_EXTERNAL_INCLUDE_DIRS
# PDD_CONV_DIFF_EXTERNAL_LIBRARIES
#
# CREATE_PDD_CONV_DIFF_PRISM_STD
# CREATE_PDD_CONV_DIFF_PRISM_STD_QUAD
# CREATE_PDD_CONV_DIFF_HYBRID_STD
# CREATE_PDD_CONV_DIFF_HYBRID_STD_QUAD
# CREATE_PDD_CONV_DIFF_PRISM_DG
# CREATE_PDD_CONV_DIFF_HYBRID_DG

# -- Add target to global list --
list(APPEND MOD_FEM_EXEC_LIST "CREATE_MOD_FEM_CONV_DIFF_PRISM_STD")
list(APPEND MOD_FEM_EXEC_LIST "CREATE_MOD_FEM_CONV_DIFF_PRISM_STD_QUAD")
list(APPEND MOD_FEM_EXEC_LIST "CREATE_MOD_FEM_CONV_DIFF_HYBRID_STD")
list(APPEND MOD_FEM_EXEC_LIST "CREATE_MOD_FEM_CONV_DIFF_HYBRID_STD_QUAD")
list(APPEND MOD_FEM_EXEC_LIST "CREATE_MOD_FEM_CONV_DIFF_PRISM2D_STD")
list(APPEND MOD_FEM_EXEC_LIST "CREATE_MOD_FEM_CONV_DIFF_PRISM2D_STD_QUAD")
list(APPEND MOD_FEM_EXEC_LIST "CREATE_MOD_FEM_CONV_DIFF_PRISM_DG")
list(APPEND MOD_FEM_EXEC_LIST "CREATE_MOD_FEM_CONV_DIFF_HYBRID_DG")
list(APPEND MOD_FEM_EXEC_LIST "CREATE_MOD_FEM_CONV_DIFF_PRISM2D_DG")
set(MOD_FEM_EXEC_LIST "${MOD_FEM_EXEC_LIST}" PARENT_SCOPE)

# -- Exec files --
set(pdd_conv_diff_srcdir "${CMAKE_SOURCE_DIR}/pdd_conv_diff")
set(PDD_CONV_DIFF_PRISM_STD_EXE "MOD_FEM_conv_diff_prism_std")
set(PDD_CONV_DIFF_PRISM_STD_QUAD_EXE "MOD_FEM_conv_diff_prism_std_quad")
set(PDD_CONV_DIFF_PRISM_DG_EXE "MOD_FEM_conv_diff_prism_dg")
set(PDD_CONV_DIFF_HYBRID_STD_EXE "MOD_FEM_conv_diff_hybrid_std")
set(PDD_CONV_DIFF_HYBRID_STD_QUAD_EXE "MOD_FEM_conv_diff_hybrid_std_quad")
set(PDD_CONV_DIFF_HYBRID_DG_EXE "MOD_FEM_conv_diff_hybrid_dg")
set(PDD_CONV_DIFF_PRISM2D_STD_EXE "MOD_FEM_conv_diff_prism2d_std")
set(PDD_CONV_DIFF_PRISM2D_STD_QUAD_EXE "MOD_FEM_conv_diff_prism2d_std_quad")
set(PDD_CONV_DIFF_PRISM2D_DG_EXE "MOD_FEM_conv_diff_prism2d_dg")

# -- Include directories --
list(APPEND PDD_CONV_DIFF_STD_INCLUDE_DIRS
  ${pdd_conv_diff_srcdir}/main
  ${pdd_conv_diff_srcdir}/main/util_std
  ${pdd_conv_diff_srcdir}/time_integration
  ${pdd_conv_diff_srcdir}/linear_solver_interface
  ${pdd_conv_diff_srcdir}/adaptation
  ${pdd_conv_diff_srcdir}/input_output
  ${pdd_conv_diff_srcdir}/weak_formulation
  ${pdd_conv_diff_srcdir}/weak_formulation/approx_std
  ${pdd_conv_diff_srcdir}/include
)
# -- Include directories --
list(APPEND PDD_CONV_DIFF_DG_INCLUDE_DIRS
  ${pdd_conv_diff_srcdir}/main
  ${pdd_conv_diff_srcdir}/main/util_dg
  ${pdd_conv_diff_srcdir}/time_integration
  ${pdd_conv_diff_srcdir}/linear_solver_interface
  ${pdd_conv_diff_srcdir}/adaptation
  ${pdd_conv_diff_srcdir}/input_output
  ${pdd_conv_diff_srcdir}/weak_formulation
  ${pdd_conv_diff_srcdir}/weak_formulation/approx_dg
  ${pdd_conv_diff_srcdir}/include
)


if(PDD_CONV_DIFF_STD_INCLUDE_DIRS)
  set(PDD_CONV_DIFF_STD_INCLUDE_DIRS ${PDD_CONV_DIFF_STD_INCLUDE_DIRS} PARENT_SCOPE)
endif()

if(PDD_CONV_DIFF_DG_INCLUDE_DIRS)
  set(PDD_CONV_DIFF_DG_INCLUDE_DIRS ${PDD_CONV_DIFF_DG_INCLUDE_DIRS} PARENT_SCOPE)
endif()


if(CREATE_MOD_FEM_CONV_DIFF_PRISM_STD)
  # -- Source files list --
  collect_src_from_include_dirs(PDD_CONV_DIFF_STD_INCLUDE_DIRS)
  # -- Target --
  include_directories(${PDD_CONV_DIFF_STD_INCLUDE_DIRS} ${PDD_CONV_DIFF_EXTERNAL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)

  add_executable(${PDD_CONV_DIFF_PRISM_STD_EXE} ${SOURCE_FILES})
  if(${MODFEM_ACCEL} STREQUAL "opencl")
    target_link_libraries(${PDD_CONV_DIFF_PRISM_STD_EXE} ${PDD_CONV_DIFF_EXTERNAL_LIBRARIES} mml_prism apl_std_lin utl_system utl_util tml_ocl ${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE} ${MODFEM_MPI_LIBS_STD})
    SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM_STD_EXE} PROPERTIES COMPILE_DEFINITIONS ${MODFEM_MPI_CODE_DEFINE} RELEASE_POSTFIX "_ocl" DEBUG_POSTFIX "_ocl_d")
  else()
    target_link_libraries(${PDD_CONV_DIFF_PRISM_STD_EXE} ${PDD_CONV_DIFF_EXTERNAL_LIBRARIES} mml_prism apl_std_lin utl_system utl_util tml_omp ${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE} ${MODFEM_MPI_LIBS_STD})
    SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM_STD_EXE} PROPERTIES COMPILE_DEFINITIONS ${MODFEM_MPI_CODE_DEFINE} DEBUG_POSTFIX "_d")
  endif()
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM_STD_EXE} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM_STD_EXE} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
endif()

#message ("VARIABLES FOR CONV_DIFF_PRISM_STD")
#message (${SOURCE_FILES})
unset(SOURCE_FILES)
#message (${PDD_CONV_DIFF_PRISM_STD_EXE})
#message (${PDD_CONV_DIFF_EXTERNAL_LIBRARIES})
#message (${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE})
#message (${MODFEM_MPI_LIBS_STD})

if(CREATE_MOD_FEM_CONV_DIFF_PRISM_STD_QUAD)
  # -- Source files list --
  collect_src_from_include_dirs(PDD_CONV_DIFF_STD_INCLUDE_DIRS)
  # -- Target --
  include_directories(${PDD_CONV_DIFF_STD_INCLUDE_DIRS} ${PDD_CONV_DIFF_EXTERNAL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)

  add_executable(${PDD_CONV_DIFF_PRISM_STD_QUAD_EXE} ${SOURCE_FILES})
  target_link_libraries(${PDD_CONV_DIFF_PRISM_STD_QUAD_EXE} ${PDD_CONV_DIFF_EXTERNAL_LIBRARIES} mml_prism apl_std_quad utl_system utl_util tml_omp ${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE} ${MODFEM_MPI_LIBS_STD})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM_STD_QUAD_EXE} PROPERTIES COMPILE_DEFINITIONS ${MODFEM_MPI_CODE_DEFINE} DEBUG_POSTFIX "_d")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM_STD_QUAD_EXE} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM_STD_QUAD_EXE} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
endif()

unset(SOURCE_FILES)

if(CREATE_MOD_FEM_CONV_DIFF_PRISM_DG)
  # -- Source files list --
  collect_src_from_include_dirs(PDD_CONV_DIFF_DG_INCLUDE_DIRS)
  # -- Target --
  include_directories(${PDD_CONV_DIFF_DG_INCLUDE_DIRS} ${PDD_CONV_DIFF_EXTERNAL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)

  add_executable(${PDD_CONV_DIFF_PRISM_DG_EXE} ${SOURCE_FILES})
  target_link_libraries(${PDD_CONV_DIFF_PRISM_DG_EXE} ${PDD_CONV_DIFF_EXTERNAL_LIBRARIES} mml_prism apl_dg_prism utl_system utl_util tml_omp ${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE} ${MODFEM_MPI_LIBS_DG})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM_DG_EXE} PROPERTIES COMPILE_DEFINITIONS ${MODFEM_MPI_CODE_DEFINE})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM_DG_EXE} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM_DG_EXE} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
endif()

unset(SOURCE_FILES)

if(CREATE_MOD_FEM_CONV_DIFF_HYBRID_STD)
  # -- Source files list --
  collect_src_from_include_dirs(PDD_CONV_DIFF_STD_INCLUDE_DIRS)
  # -- Target --
  include_directories(${PDD_CONV_DIFF_STD_INCLUDE_DIRS} ${PDD_CONV_DIFF_EXTERNAL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)

  add_executable(${PDD_CONV_DIFF_HYBRID_STD_EXE} ${SOURCE_FILES})
  target_link_libraries(${PDD_CONV_DIFF_HYBRID_STD_EXE} ${PDD_CONV_DIFF_EXTERNAL_LIBRARIES} mml_t4_prism apl_std_lin utl_system utl_util tml_omp ${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE} ${MODFEM_MPI_LIBS_STD})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_HYBRID_STD_EXE} PROPERTIES COMPILE_DEFINITIONS ${MODFEM_MPI_CODE_DEFINE} DEBUG_POSTFIX "_d")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_HYBRID_STD_EXE} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_HYBRID_STD_EXE} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
endif()

unset(SOURCE_FILES)

if(CREATE_MOD_FEM_CONV_DIFF_HYBRID_STD_QUAD)
  # -- Source files list --
  collect_src_from_include_dirs(PDD_CONV_DIFF_STD_INCLUDE_DIRS)
  # -- Target --
  include_directories(${PDD_CONV_DIFF_STD_INCLUDE_DIRS} ${PDD_CONV_DIFF_EXTERNAL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)

  add_executable(${PDD_CONV_DIFF_HYBRID_STD_QUAD_EXE} ${SOURCE_FILES})
  target_link_libraries(${PDD_CONV_DIFF_HYBRID_STD_QUAD_EXE} ${PDD_CONV_DIFF_EXTERNAL_LIBRARIES} mml_t4_prism apl_std_quad utl_system utl_util tml_omp ${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE} ${MODFEM_MPI_LIBS_STD})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_HYBRID_STD_QUAD_EXE} PROPERTIES COMPILE_DEFINITIONS ${MODFEM_MPI_CODE_DEFINE} DEBUG_POSTFIX "_d")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_HYBRID_STD_QUAD_EXE} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_HYBRID_STD_QUAD_EXE} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
endif()

unset(SOURCE_FILES)

if(CREATE_MOD_FEM_CONV_DIFF_HYBRID_DG)
  # -- Source files list --
  collect_src_from_include_dirs(PDD_CONV_DIFF_DG_INCLUDE_DIRS)
  # -- Target --
  include_directories(${PDD_CONV_DIFF_DG_INCLUDE_DIRS} ${PDD_CONV_DIFF_EXTERNAL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)

  add_executable(${PDD_CONV_DIFF_HYBRID_DG_EXE} ${SOURCE_FILES})
  target_link_libraries(${PDD_CONV_DIFF_HYBRID_DG_EXE} ${PDD_CONV_DIFF_EXTERNAL_LIBRARIES} mml_t4_prism apl_dg_prism utl_system utl_util tml_omp ${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE} ${MODFEM_MPI_LIBS_DG})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_HYBRID_DG_EXE} PROPERTIES COMPILE_DEFINITIONS ${MODFEM_MPI_CODE_DEFINE})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_HYBRID_DG_EXE} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_HYBRID_DG_EXE} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
endif()

unset(SOURCE_FILES)

if(CREATE_MOD_FEM_CONV_DIFF_PRISM2D_STD)
  # -- Source files list --
  collect_src_from_include_dirs(PDD_CONV_DIFF_STD_INCLUDE_DIRS)
  # -- Target --
  include_directories(${PDD_CONV_DIFF_STD_INCLUDE_DIRS} ${PDD_CONV_DIFF_EXTERNAL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)

  add_executable(${PDD_CONV_DIFF_PRISM2D_STD_EXE} ${SOURCE_FILES})
  target_link_libraries(${PDD_CONV_DIFF_PRISM2D_STD_EXE} ${PDD_CONV_DIFF_EXTERNAL_LIBRARIES} mml_prism_2D apl_std_lin utl_system utl_util tml_omp ${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE} ${MODFEM_MPI_LIBS_STD})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM2D_STD_EXE} PROPERTIES COMPILE_DEFINITIONS ${MODFEM_MPI_CODE_DEFINE})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM2D_STD_EXE} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM2D_STD_EXE} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
endif()

unset(SOURCE_FILES)

if(CREATE_MOD_FEM_CONV_DIFF_PRISM2D_STD_QUAD)
  # -- Source files list --
  collect_src_from_include_dirs(PDD_CONV_DIFF_STD_INCLUDE_DIRS)
  # -- Target --
  include_directories(${PDD_CONV_DIFF_STD_INCLUDE_DIRS} ${PDD_CONV_DIFF_EXTERNAL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)

  add_executable(${PDD_CONV_DIFF_PRISM2D_STD_QUAD_EXE} ${SOURCE_FILES})
  target_link_libraries(${PDD_CONV_DIFF_PRISM2D_STD_QUAD_EXE} ${PDD_CONV_DIFF_EXTERNAL_LIBRARIES} mml_prism_2D apl_std_lin utl_system utl_util tml_omp ${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE} ${MODFEM_MPI_LIBS_STD})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM2D_STD_QUAD_EXE} PROPERTIES COMPILE_DEFINITIONS ${MODFEM_MPI_CODE_DEFINE} DEBUG_POSTFIX "_d")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM2D_STD_QUAD_EXE} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM2D_STD_QUAD_EXE} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
endif()

unset(SOURCE_FILES)

if(CREATE_MOD_FEM_CONV_DIFF_PRISM2D_DG)
  # -- Source files list --
  collect_src_from_include_dirs(PDD_CONV_DIFF_DG_INCLUDE_DIRS)
  # -- Target --
  include_directories(${PDD_CONV_DIFF_DG_INCLUDE_DIRS} ${PDD_CONV_DIFF_EXTERNAL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)

  add_executable(${PDD_CONV_DIFF_PRISM2D_DG_EXE} ${SOURCE_FILES})
  target_link_libraries(${PDD_CONV_DIFF_PRISM2D_DG_EXE} ${PDD_CONV_DIFF_EXTERNAL_LIBRARIES} mml_prism_2D apl_dg_prism utl_system utl_util tml_omp ${MODFEM_DIRECT_SOLVER_MODULE} ${MODFEM_ITER_SOLVER_MODULE} ${MODFEM_MPI_LIBS_DG})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM2D_DG_EXE} PROPERTIES COMPILE_DEFINITIONS ${MODFEM_MPI_CODE_DEFINE})
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM2D_DG_EXE} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
  SET_TARGET_PROPERTIES(${PDD_CONV_DIFF_PRISM2D_DG_EXE} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
endif()
